package com.ruoyi.platform.utils;


import java.util.HashMap;
import java.util.Map;

public class ThreadMsgUtil {

    private static ThreadLocal<Map<String, String>> localMapMsg = new ThreadLocal<>();

    private static InheritableThreadLocal<String> PT_TYPE_TL = new InheritableThreadLocal<>();

    /**
     * 添加线程消息
     *
     * @param key
     * @param msg
     */
    public static void addMapMsg(String key, String msg) {
        Map<String, String> map = localMapMsg.get();
        if (BeanUtils.isEmpty(map)) {
            map = new HashMap<String, String>();
        }
        map.put(key, msg);
        localMapMsg.set(map);
    }

    /**
     * 清除消息
     */
    public static void clean() {
        localMapMsg.remove();
    }

    public static String getPtTypeTl() {
        return PT_TYPE_TL.get();
    }

}
